package com.cangshukj.web.controller.junong;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cangshukj.common.annotation.Log;
import com.cangshukj.common.core.controller.BaseController;
import com.cangshukj.common.core.domain.AjaxResult;
import com.cangshukj.common.enums.BusinessType;
import com.cangshukj.junong.domain.LandNature;
import com.cangshukj.junong.service.ILandNatureService;
import com.cangshukj.common.utils.poi.ExcelUtil;
import com.cangshukj.common.core.page.TableDataInfo;

/**
 * 土地流转性质mController
 * 
 * @author wangjie
 * @date 2025-04-01
 */
@Api(value = "/land/nature",description = "土地流转性质")
@RestController
@RequestMapping("/land/nature")
public class LandNatureController extends BaseController
{
    @Autowired
    private ILandNatureService landNatureService;

    /**
     * 查询土地流转性质列表
     */
    @ApiOperation("查询土地流转性质")
    @PreAuthorize("@ss.hasPermi('land:nature:list')")
    @GetMapping("/list")
    public TableDataInfo list(LandNature landNature)
    {
        startPage();
        List<LandNature> list = landNatureService.selectLandNatureList(landNature);
        clearPage();
        return getDataTable(list);
    }


    @ApiOperation("查询土地流转性质不分页")
    @GetMapping("/listNoPage")
    public AjaxResult listNoPage(LandNature landNature)
    {
        List<LandNature> list = landNatureService.selectLandNatureList(landNature);
        return AjaxResult.success(list);
    }


    /**
     * 获取土地流转性质m详细信息
     */
    @ApiOperation("获取土地流转性质详细信息")
    @PreAuthorize("@ss.hasPermi('land:nature:query')")
    @GetMapping(value = "/{natureId}")
    public AjaxResult getInfo(@PathVariable("natureId") String natureId)
    {
        return AjaxResult.success(landNatureService.selectLandNatureByNatureId(natureId));
    }

    /**
     * 新增土地流转性质
     */
    @ApiOperation("新增土地流转性质")
    @PreAuthorize("@ss.hasPermi('land:nature:add')")
    @Log(title = "土地流转性质m", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LandNature landNature)
    {
        landNature.setCreateBy(getUsername());
        landNature.setCreateTime(new Date());
        return toAjax(landNatureService.insertLandNature(landNature));
    }

    /**
     * 修改土地流转性质
     */
    @ApiOperation("修改土地流转性质")
    @PreAuthorize("@ss.hasPermi('land:nature:edit')")
    @Log(title = "土地流转性质m", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LandNature landNature)
    {
        landNature.setUpdateBy(getUsername());
        landNature.setUpdateTime(new Date());
        return toAjax(landNatureService.updateLandNature(landNature));
    }

    /**
     * 删除土地流转性质
     */
    @ApiOperation("删除土地流转性质")
    @PreAuthorize("@ss.hasPermi('land:nature:remove')")
    @Log(title = "土地流转性质m", businessType = BusinessType.DELETE)
	@DeleteMapping("/{natureIds}")
    public AjaxResult remove(@PathVariable String[] natureIds)
    {
        return toAjax(landNatureService.deleteLandNatureByNatureIds(natureIds));
    }
}
